package org.example.admin.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.RequiredArgsConstructor;
import org.example.admin.common.convention.result.Result;
import org.example.admin.common.convention.result.Results;
import org.example.admin.remote.ShortLinkRemoteService;
import org.example.admin.remote.dto.req.*;
import org.example.admin.remote.dto.resp.GroupShortLinkCountRespDTO;
import org.example.admin.remote.dto.resp.ShortLinkCreateRespDTO;
import org.example.admin.remote.dto.resp.ShortLinkPageRespDTO;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author weibin
 * @since 2025/10/5 16:54
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/remote/shortLink")
public class ShortLinkController {

    private final ShortLinkRemoteService shortLinkRemoteService = new ShortLinkRemoteService() {};

    @PostMapping("/moveTo")
    public Result<Void> moveTo(@RequestBody MoveToRecycleBinReqDTO requestParam) {
        shortLinkRemoteService.moveTo(requestParam);
        return Results.success();
    }

    @PostMapping("/recover")
    public Result<Void> recover(@RequestBody RecoverRecycleBinReqDTO requestParam) {
        shortLinkRemoteService.recover(requestParam);
        return Results.success();
    }

    @PostMapping("/delete")
    public Result<Void> delete(@RequestBody DeleteRecycleBinReqDTO requestParam) {
        shortLinkRemoteService.delete(requestParam);
        return Results.success();
    }

    @PostMapping("/urlTitle")
    public Result<String> getUrlTitle(@RequestParam("url") String url) {
        return shortLinkRemoteService.getUrlTitle(url);
    }

    @PostMapping("/createShortLink")
    public Result<ShortLinkCreateRespDTO> createShortLink(@RequestBody ShortLinkCreatReqDTO requestParam) {
        return shortLinkRemoteService.createShortLink(requestParam);
    }

    @PostMapping("/pageShortLink")
    public Result<IPage<ShortLinkPageRespDTO>> pageShortLink(@RequestBody ShortLinkPageReqDTO requestParam) {
        return shortLinkRemoteService.pageShortLink(requestParam);
    }

    @GetMapping("/listGroupShortLinkCount")
    public Result<List<GroupShortLinkCountRespDTO>> listGroupShortLinkCount(@RequestParam("requestParam") List<String> requestParam) {
        return shortLinkRemoteService.listGroupShortLinkCount(requestParam);
    }

    @GetMapping("/updateShortLink")
    public Result<Void> updateShortLink(@RequestBody ShortLinkUpdateReqDTO requestParam) {
        return shortLinkRemoteService.updateShortLink(requestParam);
    }


}
